//
//  Contact_View.m
//  VivaModa
//
//  Created by Owly MacBook on 06.02.13.
//  Copyright (c) 2013 private_busines. All rights reserved.
//

#import "Contact_View.h"

@interface Contact_View ()

@end

@implementation Contact_View
@synthesize contactText_text;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}



-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    [self.navigationItem setTitle:@"Контакты"];
}


-(void)enterContentContacts{
    NSString* txt = @"Контактная информация.\n"
    "ИП «Витько Андрей Олегович»\n"
    "ОГРН: 311774607700121\n"
    "Москва, улица Большая Очаковская, дом 47а, строение 1\n"
    "телефоны: (495)795-47-65 с 10 до 18, включая субботу и воскресение.\n"
    "\n"
    "Розничные магазины.\n"
    "Бутики эксклюзивных подарочных коллекций «VIVA» эксклюзивные коллекции подарков и гламурных аксессуаров для дома\n"
    
    "ТЦ «Атриум», ул Земляной Вал, 33, 1этаж, тел.: (495) 510 17 08\n"
    "ТРЦ \"Европейский\" 1этаж, \nтел.: (495) 229 79 37\n"
    "ТЦ \"Горки-2\" 1этаж, тел.: (495) 781 36 36\n";
    NSMutableAttributedString* attrStr = [NSMutableAttributedString attributedStringWithString:txt];
    [attrStr setFont:[UIFont systemFontOfSize:14]];
    
    [attrStr setTextColor:[UIColor colorWithRed:94/255.f green:94/255.f blue:94/255.f alpha:1.0]];
    //NSRange range1 = [txt rangeOfString:@"(495)795-47-65"];
    //[attrStr setTextColor:[UIColor blueColor] range:range1];
    
    
    //NSRange range2 = [txt rangeOfString:@"(495) 510 17 08"];
    //[attrStr setTextColor:[UIColor blueColor] range:range2];
    
    
    //NSRange range3 = [txt rangeOfString:@"(495) 229 79 37"];
    //[attrStr setTextColor:[UIColor blueColor] range:range3];
    
    //NSRange range4 = [txt rangeOfString:@"(495) 781 36 36"];
    //[attrStr setTextColor:[UIColor blueColor] range:range4];
    
    
    
    

    
    
    
    contactText_text.attributedText = attrStr;
    

    [contactText_text addCustomLink:[NSURL URLWithString:@"tel:(495)795-47-65"] inRange:[txt rangeOfString:@"(495)795-47-65"]];
    
    [contactText_text addCustomLink:[NSURL URLWithString:@"tel:(495) 510 17 08"] inRange:[txt rangeOfString:@"(495) 510 17 08"]];
    
    
    [contactText_text addCustomLink:[NSURL URLWithString:@"tel:(495) 229 79 37"] inRange:[txt rangeOfString:@"(495) 229 79 37"]];
    
    [contactText_text addCustomLink:[NSURL URLWithString:@"tel:(495) 781 36 36"] inRange:[txt rangeOfString:@"(495) 781 36 36"]];
    
    
    
    
    //[contactText_text addCustomLink:[NSURL URLWithString:@"http://google.com"] inRange:[txt rangeOfString:@"Земляной"]];
    [contactText_text setBackgroundColor:[UIColor clearColor]];
}



- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self setNavigationTitle];
    [self addCustomBackButton];
    self.view.backgroundColor = [Singleton sharedMySingleton].backgroundTableView;
    
    
    [self enterContentContacts];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)setNavigationTitle{
    UILabel *lblTitle = [[UILabel alloc] init];
    lblTitle.text = @" Контакты";
    lblTitle.backgroundColor = [UIColor clearColor];
    lblTitle.textColor = [UIColor colorWithRed:242.0/255.0 green:240.0/255.0 blue:234.0/255.0 alpha:1];
    
    lblTitle.font = [UIFont fontWithName:@"American Retro" size:27.0];
    [lblTitle sizeToFit];
    
    self.navigationItem.titleView = lblTitle;
}



-(void)addCustomBackButton{
    UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 71, 29)];
    //[backButton setImage:[[UIImage imageNamed:@"img_back_btn.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10) ] forState:UIControlStateNormal];
    
    [backButton setBackgroundImage:[[UIImage imageNamed:@"img_back_btn.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(8, 20, 20, 20) ] forState:UIControlStateNormal];
    
    [backButton setTitle:@" Инфо" forState:UIControlStateNormal];
    [backButton.titleLabel setFont:[UIFont fontWithName:@"Arial-BoldMT" size:12]];
    
    [backButton setShowsTouchWhenHighlighted:NO];
    [backButton addTarget:self action:@selector(popViewControllerWithAnimation) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *barBackItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.hidesBackButton = TRUE;
    self.navigationItem.leftBarButtonItem = barBackItem;
}

-(void)popViewControllerWithAnimation{
    [self.navigationController popViewControllerAnimated:YES];
}


@end
